<?php
class HomeBaseTypeValidate extends Validate {
	protected function valid() {
		$result = array ();
		if (empty ( $this->param ['viewSimpleDataTypeName'] )) {
			$result ['result'] = 'error';
			$result ['error'] = '分类名称不能为空';
			return $result;
		}
		if (empty ( $this->param ['viewSimpleDataTypeDesc'] )) {
			$result ['result'] = 'error';
			$result ['error'] = '分类描述不能为空';
			return $result;
		}
		if (empty ( $this->param ['viewSimpleDataTypeParentId'] )) {
			$this->param ['viewSimpleDataTypeParentId'] = 0; // 设为顶级父类
		}
		if (empty ( $this->param ['viewSimpleDataTypeOrder'] )) {
			$this->param ['prodTypeOrder'] = 0; // 排序号设为0
		}
		if (isset ( $this->param ['viewSimpleDataTypeOrder'] )) {
			if (! preg_match ( "/^\d+$/", $this->param ['viewSimpleDataTypeOrder']) 
				|| $this->param ['viewSimpleDataTypeOrder'] > 99999 ) {
				$result ['result'] = 'error';
				$result ['error'] = '排序号只能为小于99999正整数';
				return $result;
			}
		}
		$result ['result'] = 'success';
		return $result;
	}
}
?>